﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard;
using System.Web.Mvc;
using Orchard.Mvc;
using Orchard.Users.Models;
using Orchard.Mvc.Extensions;
using Orchard.Utility.Extensions;
using Orchard.ContentManagement;

namespace Contrib.Mod.AccountWidgets.Controllers
{
    public class ShapesController : Controller
    {
        private readonly IOrchardServices _orchardServices;

        public ShapesController(IOrchardServices orchardServices)
        {
            _orchardServices = orchardServices;
        }


        public ActionResult LoginShape()
        {
            var shape = _orchardServices.New.LogOn();

            return new ShapeResult(this, shape);
        }

        public ActionResult RegisterShape()
        {
            var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
            if (!registrationSettings.UsersCanRegister)
            {
                return HttpNotFound();
            }

            var shape = _orchardServices.New.Register();

            return new ShapeResult(this, shape);
        }
    }
}